cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jburwell <...@git.apache.org>
Subject [GitHub] cloudstack pull request: DAO: Hit the cache for entity flagged as ...
Date Fri, 06 May 2016 14:20:37 GMT
Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1532#discussion_r62335611
  
    --- Diff: framework/db/src/com/cloud/utils/db/GenericDaoBase.java ---
    @@ -969,7 +969,12 @@ public T findByUuidIncludingRemoved(final String uuid) {
         @Override
         @DB()
         public T findByIdIncludingRemoved(ID id) {
    -        return findById(id, true, null);
    +        if (_cache != null) {
    +            final Element element = _cache.get(id);
    +            return element == null ? findById(id, true, null) : (T)element.getObjectValue();
    +        } else {
    --- End diff --
    
    @dahn if the ``_cache`` is not optional then I agree. It should probably be something
like the following:
    
    ```
    if (_cache == null) {
        throw new IllegalStateException("The cache has not been properly initialized for DAO
" + this.getClass().getSimpleName());
    }
    
    final Element element = _cache.get(id);
    return element == null ? findById(id, true, null) : (T) element.getObjectValue();
    ```
    
    Would you agree?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message