コード例 #1
0
            public long?GetExpiresAfter(K key)
            {
                policy.RequireNonNull <K>(key);

                K           lookupKey = policy.cache.nodeFactory.NewLookupKey(key);
                Node <K, V> node      = policy.cache.data[lookupKey];

                if (node == null)
                {
                    return(null);
                }

                long duration = node.VariableTime - policy.cache.ExpirationTicker.Ticks();

                return((duration <= 0) ? null : (long?)duration);
            }
コード例 #2
0
            public long?AgeOf(K key)
            {
                policy.RequireNonNull <K>(key);

                K           lookupKey = policy.cache.nodeFactory.NewLookupKey(key);
                Node <K, V> node      = policy.cache.data[key];

                if (node == null)
                {
                    return(null);
                }

                long age = policy.cache.ExpirationTicker.Ticks() - node.WriteTime;

                return((age > policy.cache.ExpiresAfterWriteNanos) ? new long?() : age);
            }
コード例 #3
0
            public int?WeightOf(K key)
            {
                policy.RequireNonNull <K>(key);

                if (!IsWeighted)
                {
                    return(null);
                }

                Node <K, V> node = null;

                policy.cache.data.TryGetValue(policy.cache.nodeFactory.NewLookupKey(key), out node);

                if (node == null)
                {
                    return(null);
                }

                lock (node)
                {
                    return(node.Weight);
                }
            }