├── .github └── workflows │ └── blank.yml ├── README.md ├── docs ├── cachetools │ ├── cache2q.html │ ├── cachelru.html │ ├── containers │ │ ├── hashmap.html │ │ ├── hashmap │ │ │ ├── HashMap.KeyPointer.html │ │ │ ├── HashMap.addIfMissed.html │ │ │ ├── HashMap.byKey.html │ │ │ ├── HashMap.byPair.html │ │ │ ├── HashMap.byValue.html │ │ │ ├── HashMap.clear.html │ │ │ ├── HashMap.get.html │ │ │ ├── HashMap.getOrAdd.html │ │ │ ├── HashMap.grow_factor.html │ │ │ ├── HashMap.html │ │ │ ├── HashMap.length.html │ │ │ ├── HashMap.opBinaryRight.html │ │ │ ├── HashMap.opIndex.html │ │ │ ├── HashMap.opIndexAssign.html │ │ │ ├── HashMap.put.html │ │ │ ├── HashMap.remove.html │ │ │ ├── HashMap.require.html │ │ │ └── HashMap.size.html │ │ ├── lists.html │ │ ├── lists │ │ │ ├── CompressedList.Page._freeMap.html │ │ │ ├── CompressedList.Page.html │ │ │ ├── CompressedList.back.html │ │ │ ├── CompressedList.clear.html │ │ │ ├── CompressedList.empty.html │ │ │ ├── CompressedList.front.html │ │ │ ├── CompressedList.html │ │ │ ├── CompressedList.insertBack.html │ │ │ ├── CompressedList.insertFront.html │ │ │ ├── CompressedList.length.html │ │ │ ├── CompressedList.popBack.html │ │ │ ├── CompressedList.popFront.html │ │ │ ├── CompressedList.range.html │ │ │ ├── CompressedList.remove.html │ │ │ ├── DList.Node.html │ │ │ ├── DList.Node.payload.html │ │ │ ├── DList.clear.html │ │ │ ├── DList.head.html │ │ │ ├── DList.html │ │ │ ├── DList.insertBack.html │ │ │ ├── DList.insertFront.html │ │ │ ├── DList.insert_first.html │ │ │ ├── DList.insert_last.html │ │ │ ├── DList.length.html │ │ │ ├── DList.move_to_head.html │ │ │ ├── DList.move_to_tail.html │ │ │ ├── DList.popBack.html │ │ │ ├── DList.popFront.html │ │ │ ├── DList.range.html │ │ │ ├── DList.remove.html │ │ │ ├── DList.tail.html │ │ │ ├── MultiDList.html │ │ │ ├── SList.back.html │ │ │ ├── SList.clear.html │ │ │ ├── SList.empty.html │ │ │ ├── SList.front.html │ │ │ ├── SList.html │ │ │ ├── SList.insertBack.html │ │ │ ├── SList.insertFront.html │ │ │ ├── SList.length.html │ │ │ ├── SList.popFront.html │ │ │ ├── SList.range.html │ │ │ └── SList.remove_by_predicate.html │ │ ├── orderedhashmap.html │ │ ├── orderedhashmap │ │ │ ├── OrderedHashMap.addIfMissed.html │ │ │ ├── OrderedHashMap.byKey.html │ │ │ ├── OrderedHashMap.byPair.html │ │ │ ├── OrderedHashMap.byValue.html │ │ │ ├── OrderedHashMap.clear.html │ │ │ ├── OrderedHashMap.get.html │ │ │ ├── OrderedHashMap.getOrAdd.html │ │ │ ├── OrderedHashMap.html │ │ │ ├── OrderedHashMap.length.html │ │ │ ├── OrderedHashMap.opBinaryRight.html │ │ │ ├── OrderedHashMap.opIndex.html │ │ │ ├── OrderedHashMap.opIndexAssign.html │ │ │ ├── OrderedHashMap.put.html │ │ │ └── OrderedHashMap.remove.html │ │ ├── set.html │ │ └── set │ │ │ ├── Set.add.html │ │ │ ├── Set.create.html │ │ │ ├── Set.difference.html │ │ │ ├── Set.intersection.html │ │ │ ├── Set.iterate.html │ │ │ ├── Set.join.html │ │ │ ├── Set.length.html │ │ │ ├── Set.opBinaryRight.html │ │ │ ├── Set.remove.html │ │ │ └── set.html │ ├── interfaces.html │ └── interfaces │ │ ├── PutResult.html │ │ ├── PutResultFlag.html │ │ ├── TTL.html │ │ ├── TTL.opUnary.html │ │ ├── TTL.this.html │ │ ├── TTL.useDefault.html │ │ └── TTL.value.html ├── file_hashes.json ├── images │ └── ddox │ │ ├── alias.png │ │ ├── class.png │ │ ├── enum.png │ │ ├── enummember.png │ │ ├── function.png │ │ ├── inherited.png │ │ ├── interface.png │ │ ├── module.png │ │ ├── package.png │ │ ├── private.png │ │ ├── property.png │ │ ├── protected.png │ │ ├── struct.png │ │ ├── template.png │ │ └── variable.png ├── index.html ├── prettify │ └── prettify.css ├── scripts │ ├── ddox.js │ └── jquery.js ├── sitemap.xml ├── styles │ └── ddox.css └── symbols.js ├── dub.json ├── source └── cachetools │ ├── cache.d │ ├── cache2q.d │ ├── cachelru.d │ ├── containers │ ├── README.md │ ├── hashmap.d │ ├── lists.d │ ├── orderedhashmap.d │ ├── package.d │ └── set.d │ ├── hash.d │ ├── interfaces.d │ ├── internal.d │ └── package.d └── testhash ├── .gitignore ├── README.md ├── dub.json ├── source └── app.d └── t8.shakespeare.txt /.github/workflows/blank.yml: -------------------------------------------------------------------------------- 1 | name: Run all D Tests 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | test: 6 | name: Dub Tests 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | os: [ubuntu-latest, macOS-latest] 11 | dc: [dmd, ldc] 12 | # You have to exclude gdc configurations from non-linux OSes 13 | 14 | runs-on: ${{ matrix.os }} 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Install D compiler 19 | uses: dlang-community/setup-dlang@v2 20 | with: 21 | compiler: ${{ matrix.dc }} 22 | dub: latest 23 | 24 | - name: Run tests 25 | shell: bash 26 | run: dub -q test 27 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Module cachetools.containers.hashmap 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Module cachetools.containers.hashmap

74 |
75 |
76 |

Structs

77 | 78 | 79 | 80 | 81 | 82 | 83 | 88 | 89 | 90 |
NameDescription
84 | 85 | HashMap 86 | 87 |
91 |
92 | 115 |
116 | 117 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.KeyPointer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.keyPointer 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.keyPointer

74 |
75 | 76 |
77 | HashMap.KeyPointer keyPointer 78 | ( 79 |
80 |   K key 81 |
82 | ); 83 |
84 |
85 |
86 | 87 | 88 | 111 |
112 | 113 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.byKey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.byKey 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.byKey

iterator by keys 74 |

75 |
76 | 77 |
78 | auto auto byKey() pure @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.byPair.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.byPair 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.byPair

iterator by key/value pairs 74 |

75 |
76 | 77 |
78 | auto auto byPair() pure @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.byValue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.byValue 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.byValue

iterator by values 74 |

75 |
76 | 77 |
78 | auto auto byValue() pure @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.clear 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.clear

throw away all keys 74 |

75 |
76 | 77 |
78 | void clear() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.length

get numter of keys in table 74 |

75 |
76 | 77 |
78 | auto auto length() const pure nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.opIndexAssign.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.opIndexAssign 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.opIndexAssign

map[k] = v; 74 |

75 |
76 | 77 |
78 | void opIndexAssign(K) 79 | ( 80 |
81 |   V v, 82 |
83 |   K k 84 |
85 | ); 86 |
87 |
88 |
89 |
90 | 91 | 92 | 115 |
116 | 117 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.remove.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.remove 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.remove

remomve key from hash. 74 |

75 |
76 | 77 |
78 | bool remove 79 | ( 80 |
81 |   K k 82 |
83 | ); 84 |
85 |
86 |
87 | 88 |

Returns

89 |

true if actually removed, false otherwise. 90 |

91 |
92 | 93 | 116 |
117 | 118 | -------------------------------------------------------------------------------- /docs/cachetools/containers/hashmap/HashMap.size.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function HashMap.size 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function HashMap.size

get current buckets number 74 |

75 |
76 | 77 |
78 | auto auto size() const pure nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.back.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.back 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.back

List back item. 74 |

75 |
76 | 77 |
78 | T back() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.clear 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.clear

remove anything from list 74 |

75 |
76 | 77 |
78 | void clear() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.empty.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.empty 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.empty

Is list empty? 74 |

75 |
76 | 77 |
78 | bool empty() const @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.front 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.front

List front item 74 |

75 |
76 | 77 |
78 | T front() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.insertBack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.insertBack 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.insertBack

Insert item back. 74 |

75 |
76 | 77 |
78 | NodePointer insertBack 79 | ( 80 |
81 |   T v 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.insertFront.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.insertFront 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.insertFront

Insert item at front. 74 |

75 |
76 | 77 |
78 | NodePointer insertFront 79 | ( 80 |
81 |   T v 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.length

Items in the list. 74 |

75 |
76 | 77 |
78 | ulong length() const @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.popBack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.popBack 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.popBack

Pop back item from list. 74 |

75 |
76 | 77 |
78 | void popBack() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.popFront.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.popFront 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.popFront

Pop front item 74 |

75 |
76 | 77 |
78 | void popFront() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.range.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.range 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.range

Iterator over items. 74 |

75 |
76 | 77 |
78 | Range range() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/CompressedList.remove.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function CompressedList.remove 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function CompressedList.remove

remove node (by 'Pointer') 74 |

75 |
76 | 77 |
78 | void remove 79 | ( 80 |
81 |   ref NodePointer p 82 |
83 | ) @system; 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/DList.clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function DList.clear 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function DList.clear

remove all items from list 74 |

75 |
76 | 77 |
78 | void clear() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/DList.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function DList.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function DList.length

Number of items in list 74 |

75 |
76 | 77 |
78 | ulong length() const pure nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/DList.popBack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function DList.popBack 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function DList.popBack

pop last item. 74 |

75 |
76 | 77 |
78 | bool popBack() @safe; 79 |
80 |
81 |
82 | 83 |

Returns

84 |

true if list was not empty 85 |

86 |
87 | 88 | 111 |
112 | 113 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/DList.popFront.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function DList.popFront 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function DList.popFront

pop front item. 74 |

75 |
76 | 77 |
78 | bool popFront() @safe; 79 |
80 |
81 |
82 | 83 |

Returns

84 |

true if list was not empty 85 |

86 |
87 | 88 | 111 |
112 | 113 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/DList.range.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function DList.range 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function DList.range

Iterator over items 74 |

75 |
76 | 77 |
78 | Range range() @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/MultiDList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Struct MultiDList 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Struct MultiDList

N-way multilist 74 |

75 |
76 | 77 |
78 | struct MultiDList(T, int N, Allocator, bool GCRangesAllowed = true) 79 | ; 80 |
81 |
82 |
83 | 84 | 85 | 108 |
109 | 110 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.back.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.back 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.back

back item 74 |

75 |
76 | 77 |
78 | T back() pure @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.clear 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.clear

clear everything 74 |

75 |
76 | 77 |
78 | void clear() @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.empty.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.empty 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.empty

item empty? 74 |

75 |
76 | 77 |
78 | bool empty() const @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.front.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.front 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.front

front item 74 |

75 |
76 | 77 |
78 | T front() pure @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.insertBack.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.insertBack 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.insertBack

insert item at back 74 |

75 |
76 | 77 |
78 | void insertBack 79 | ( 80 |
81 |   T v 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.insertFront.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.insertFront 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.insertFront

insert item at front 74 |

75 |
76 | 77 |
78 | void insertFront 79 | ( 80 |
81 |   T v 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.length

number of items in list 74 |

75 |
76 | 77 |
78 | ulong length() const pure nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.popFront.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.popFront 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.popFront

pop front item 74 |

75 |
76 | 77 |
78 | T popFront() nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/lists/SList.range.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function SList.range 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function SList.range

return range over list 74 |

75 |
76 | 77 |
78 | Range!T range(); 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Module cachetools.containers.orderedhashmap 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Module cachetools.containers.orderedhashmap

74 |
75 |
76 |

Structs

77 | 78 | 79 | 80 | 81 | 82 | 83 | 88 | 89 | 90 |
NameDescription
84 | 85 | OrderedHashMap 86 | 87 |
91 |
92 | 115 |
116 | 117 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.byKey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.byKey 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.byKey

iterator by keys 74 |

75 |
76 | 77 |
78 | auto auto byKey() pure @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.byPair.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.byPair 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.byPair

74 |
75 | 76 |
77 | auto auto byPair() pure @nogc @safe; 78 |
79 |
80 |
81 | 82 | 83 | 106 |
107 | 108 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.byValue.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.byValue 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.byValue

iterator by value 74 |

75 |
76 | 77 |
78 | auto auto byValue() pure @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.clear 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.clear

74 |
75 | 76 |
77 | void clear() @safe; 78 |
79 |
80 |
81 | 82 | 83 | 106 |
107 | 108 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.length

get numter of keys in table 74 |

75 |
76 | 77 |
78 | auto auto length() const pure nothrow @nogc @safe; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/orderedhashmap/OrderedHashMap.remove.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function OrderedHashMap.remove 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function OrderedHashMap.remove

74 |
75 | 76 |
77 | bool remove 78 | ( 79 |
80 |   K k 81 |
82 | ) @safe; 83 |
84 |
85 |
86 | 87 | 88 | 111 |
112 | 113 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.add.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.add 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.add

add element to set 74 |

75 |
76 | 77 |
78 | void add(K) 79 | ( 80 |
81 |   K k 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.create.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.create 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.create

Fill set from range 74 |

75 |
76 | 77 |
78 | void create(R) 79 | ( 80 |
81 |   R range 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.difference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.difference 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.difference

create difference of two sets 74 |

75 |
76 | 77 |
78 | auto auto difference(K) 79 | ( 80 |
81 |   Set!K other 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.intersection.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.intersection 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.intersection

create intersection of two sets 74 |

75 |
76 | 77 |
78 | auto auto intersection(K) 79 | ( 80 |
81 |   Set!K other 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.iterate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.iterate 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.iterate

iterate over items 74 |

75 |
76 | 77 |
78 | auto auto iterate(); 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.join.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.join 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.join

join other set to this set 74 |

75 |
76 | 77 |
78 | void join(K) 79 | ( 80 |
81 |   Set!K other 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.length.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.length 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.length

number of items in set 74 |

75 |
76 | 77 |
78 | auto auto length() const; 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/containers/set/Set.remove.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function Set.remove 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function Set.remove

remove element from set 74 |

75 |
76 | 77 |
78 | void remove(K) 79 | ( 80 |
81 |   K k 82 |
83 | ); 84 |
85 |
86 |
87 | 88 | 89 | 112 |
113 | 114 | -------------------------------------------------------------------------------- /docs/cachetools/interfaces/PutResult.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Alias PutResult 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Alias PutResult

74 |
75 | 76 |
77 | alias PutResult 78 | = std.typecons.BitFlags!(cachetools.interfaces.PutResultFlag,0); 79 |
80 |
81 |
82 | 83 | 84 | 107 |
108 | 109 | -------------------------------------------------------------------------------- /docs/cachetools/interfaces/PutResultFlag.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Enum PutResultFlag 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Enum PutResultFlag

74 |
75 | 76 |
77 | enum PutResultFlag 78 | : int { ... } 79 |
80 |
81 |
82 | 83 |

Enum members

84 | 85 | 86 | 87 | 88 | 89 |
NameDescription
90 |
91 | 92 | 115 |
116 | 117 | -------------------------------------------------------------------------------- /docs/cachetools/interfaces/TTL.useDefault.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function TTL.useDefault 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function TTL.useDefault

True if this TTL means - use default value for this cache 74 |

75 |
76 | 77 |
78 | bool useDefault() pure nothrow @nogc @safe const; 79 |
80 |
81 |
82 |
83 | 84 | 85 | 108 |
109 | 110 | -------------------------------------------------------------------------------- /docs/cachetools/interfaces/TTL.value.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Function TTL.value 6 | 7 | 8 | 9 | 10 | 11 | 72 |
73 |

Function TTL.value

return value encapsulated by this ttl 74 |

75 |
76 | 77 |
78 | core.time.Duration value() pure nothrow @nogc @safe const; 79 |
80 |
81 |
82 |
83 | 84 | 85 | 108 |
109 | 110 | -------------------------------------------------------------------------------- /docs/images/ddox/alias.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/alias.png -------------------------------------------------------------------------------- /docs/images/ddox/class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/class.png -------------------------------------------------------------------------------- /docs/images/ddox/enum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/enum.png -------------------------------------------------------------------------------- /docs/images/ddox/enummember.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/enummember.png -------------------------------------------------------------------------------- /docs/images/ddox/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/function.png -------------------------------------------------------------------------------- /docs/images/ddox/inherited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/inherited.png -------------------------------------------------------------------------------- /docs/images/ddox/interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/interface.png -------------------------------------------------------------------------------- /docs/images/ddox/module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/module.png -------------------------------------------------------------------------------- /docs/images/ddox/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/package.png -------------------------------------------------------------------------------- /docs/images/ddox/private.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/private.png -------------------------------------------------------------------------------- /docs/images/ddox/property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/property.png -------------------------------------------------------------------------------- /docs/images/ddox/protected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/protected.png -------------------------------------------------------------------------------- /docs/images/ddox/struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/struct.png -------------------------------------------------------------------------------- /docs/images/ddox/template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/template.png -------------------------------------------------------------------------------- /docs/images/ddox/variable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ikod/cachetools/d63ac8ee5f4b51669d9927ddf531fd821e439bd0/docs/images/ddox/variable.png -------------------------------------------------------------------------------- /docs/prettify/prettify.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | 3 | /* SPAN elements with the classes below are added by prettyprint. */ 4 | .pln { color: #222 } /* plain text */ 5 | pre .pln, div.prototype .pln { color: #fff } /* plain text */ 6 | 7 | @media screen { 8 | pre .str { color: #ffe7b6 } /* string content */ 9 | pre .typ { color: #9ad452 } /* a type name */ 10 | pre .lit { color: #ffe7b6 } /* a literal value */ 11 | pre .pun, div.prototype .pun { color: #fff } 12 | 13 | .spc { color: #a0a } /* special token sequence */ 14 | .str { color: #842 } /* string content */ 15 | .kwd { color: #ffaa00 } /* a keyword */ 16 | .com { color: #888 } /* a comment */ 17 | .typ { color: #693 } /* a type name */ 18 | .lit { color: #875 } /* a literal value */ 19 | /* punctuation, lisp open bracket, lisp close bracket */ 20 | .pun, .opn, .clo { color: #222 } 21 | .tag { color: #ffaa00 } /* a markup tag name */ 22 | .atn { color: #9ad452 } /* a markup attribute name */ 23 | .atv { color: #ffe7b6 } /* a markup attribute value */ 24 | .dec, .var { color: #aaa } /* a declaration; a variable name */ 25 | .fun { color: red } /* a function name */ 26 | } 27 | 28 | /* Use higher contrast and text-weight for printable form. */ 29 | @media print, projection { 30 | .spc { color: #606 } /* special token sequence */ 31 | .str { color: #060 } 32 | .kwd { color: #006; font-weight: bold } 33 | .com { color: #600; font-style: italic } 34 | .typ { color: #404; font-weight: bold } 35 | .lit { color: #044 } 36 | .pun, .opn, .clo { color: #440 } 37 | .tag { color: #006; font-weight: bold } 38 | .atn { color: #404 } 39 | .atv { color: #060 } 40 | } 41 | 42 | /* Put a border around prettyprinted code snippets. */ 43 | pre.prettyprint, pre.code, div.prototype { 44 | padding: 1em 0.5em; 45 | background-color: #282822; 46 | border: 1px solid black; 47 | color: white; 48 | max-width: 100em; 49 | overflow: auto; 50 | } 51 | 52 | /* Specify class=linenums on a pre to get line numbering */ 53 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ 54 | li.L0, 55 | li.L1, 56 | li.L2, 57 | li.L3, 58 | li.L5, 59 | li.L6, 60 | li.L7, 61 | li.L8 { list-style-type: none } 62 | /* Alternate shading for lines */ 63 | li.L1, 64 | li.L3, 65 | li.L5, 66 | li.L7, 67 | li.L9 { background: #222222 } 68 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cachetools", 3 | "authors": [ 4 | "Igor Khasilev" 5 | ], 6 | "dependencies": { 7 | "automem": "*" 8 | }, 9 | "configurations":[ 10 | { 11 | "name": "unittest", 12 | "targetType": "executable", 13 | "versions": ["TestingCacheTools"], 14 | "preBuildCommands": [ 15 | "dub run --compiler=$$DC unit-threaded -c gen_ut_main -- -f bin/ut.d" 16 | ], 17 | "dependencies": { 18 | "unit-threaded": "*" 19 | }, 20 | "excludedSourceFiles": [ 21 | "src/main.d" 22 | ], 23 | "mainSourceFile": "bin/ut.d" 24 | }, 25 | { 26 | "name": "library", 27 | "targetType": "library" 28 | }, 29 | { 30 | "name": "application", 31 | "targetType": "executable" 32 | } 33 | ], 34 | "buildTypes": { 35 | "debug": { 36 | "buildOptions": [ 37 | "debugMode", 38 | "debugInfo" 39 | ], 40 | "dflags-dmd": [ 41 | "-g", "-gf" 42 | ], 43 | "dflags-ldc": [ 44 | "-d-debug=cachetools" 45 | ], 46 | "debugVersions": [ 47 | "cachetools" 48 | ] 49 | }, 50 | "unittest": { 51 | "buildOptions": [ 52 | "unittests", "debugMode", "debugInfo" 53 | ], 54 | "dflags-dmd": [ 55 | "-g", "-gf" 56 | ], 57 | "dflags-ldc": [ 58 | "-d-debug=cachetools" 59 | ], 60 | "debugVersions": [ 61 | "cachetools" 62 | ] 63 | }, 64 | "profile": { 65 | "buildOptions": [ 66 | "profile", "optimize", "inline", "debugInfo" 67 | ], 68 | "dflags-dmd": [ 69 | "-g", "-gf", "-release" 70 | ], 71 | "dflags-ldc": [ 72 | "-d-debug=cachetools" 73 | ], 74 | "debugVersions": [ 75 | "cachetools" 76 | ] 77 | } 78 | }, 79 | "sourcePaths": ["source"], 80 | "importPaths": ["source"], 81 | "description": "Collection of cache strategies", 82 | "license": "MIT" 83 | } 84 | -------------------------------------------------------------------------------- /source/cachetools/cache.d: -------------------------------------------------------------------------------- 1 | module cachetools.cache; 2 | 3 | public import cachetools.cachelru; 4 | public import cachetools.cache2q; 5 | 6 | -------------------------------------------------------------------------------- /source/cachetools/containers/package.d: -------------------------------------------------------------------------------- 1 | module cachetools.containers; 2 | 3 | public import cachetools.containers.lists; 4 | public import cachetools.containers.hashmap; 5 | public import cachetools.containers.orderedhashmap; 6 | -------------------------------------------------------------------------------- /source/cachetools/hash.d: -------------------------------------------------------------------------------- 1 | module cachetools.hash; 2 | 3 | import std.traits; 4 | 5 | /// 6 | /// For classes (and structs with toHash method) we use v.toHash() to compute hash. 7 | /// =============================================================================== 8 | /// toHash method CAN BE @nogc or not. HashMap 'nogc' properties is inherited from this method. 9 | /// toHash method MUST BE @safe or @trusted, as all HashMap code alredy safe. 10 | /// 11 | /// See also: https://dlang.org/spec/hash-map.html#using_classes_as_key 12 | /// and https://dlang.org/spec/hash-map.html#using_struct_as_key 13 | /// 14 | bool UseToHashMethod(T)() { 15 | return (is(T == class) || (is(T==struct) && __traits(compiles, { 16 | T v = T.init; hash_t h = v.toHash(); 17 | }))); 18 | } 19 | 20 | hash_t hash_function(T)(T v) /* @safe @nogc inherited from toHash method */ 21 | if ( UseToHashMethod!T ) 22 | { 23 | return v.toHash(); 24 | } 25 | 26 | hash_t hash_function(T)(in T v) @nogc @trusted 27 | if ( !UseToHashMethod!T ) 28 | { 29 | static if ( isNumeric!T ) { 30 | enum m = 0x5bd1e995; 31 | hash_t h = v; 32 | h ^= h >> 13; 33 | h *= m; 34 | h ^= h >> 15; 35 | return h; 36 | } 37 | else static if ( is(T == string) ) { 38 | // // FNV-1a hash 39 | // ulong h = 0xcbf29ce484222325; 40 | // foreach (const ubyte c; cast(ubyte[]) v) 41 | // { 42 | // h ^= c; 43 | // h *= 0x100000001b3; 44 | // } 45 | // return cast(hash_t)h; 46 | import core.internal.hash : bytesHash; 47 | return bytesHash(cast(void*)v.ptr, v.length, 0); 48 | } 49 | else 50 | { 51 | const(ubyte)[] bytes = (cast(const(ubyte)*)&v)[0 .. T.sizeof]; 52 | ulong h = 0xcbf29ce484222325; 53 | foreach (const ubyte c; bytes) 54 | { 55 | h ^= c; 56 | h *= 0x100000001b3; 57 | } 58 | return cast(hash_t)h; 59 | } 60 | } 61 | 62 | @safe unittest 63 | { 64 | //assert(hash_function("abc") == cast(hash_t)0xe71fa2190541574b); 65 | 66 | struct A0 {} 67 | assert(!UseToHashMethod!A0); 68 | 69 | struct A1 { 70 | hash_t toHash() const @safe { 71 | return 0; 72 | } 73 | } 74 | assert(UseToHashMethod!A1); 75 | 76 | // class with toHash override - will use toHash 77 | class C0 { 78 | override hash_t toHash() const @safe { 79 | return 0; 80 | } 81 | } 82 | assert(UseToHashMethod!C0); 83 | C0 c0 = new C0(); 84 | assert(c0.toHash() == 0); 85 | 86 | // class without toHash override - use Object.toHash method 87 | class C1 { 88 | } 89 | assert(UseToHashMethod!C1); 90 | } 91 | -------------------------------------------------------------------------------- /source/cachetools/interfaces.d: -------------------------------------------------------------------------------- 1 | /// 2 | module cachetools.interfaces; 3 | 4 | private { 5 | import std.typecons; 6 | import std.datetime; 7 | import core.time; 8 | import std.typecons; 9 | } 10 | 11 | private import cachetools.internal; 12 | 13 | // 14 | // cache have aspects: 15 | // 1. storage: hashmap and some kind of order of elements 16 | // 2. stream of evicted elements, which user may want to handle(slose files, sockets, etc) 17 | // 3. eviction policy (condition to start/stop evinction) 18 | // 19 | 20 | /// 21 | enum PutResultFlag 22 | { 23 | None, 24 | Inserted = 1 << 0, 25 | Replaced = 1 << 1, 26 | Evicted = 1 << 2 27 | } 28 | /// 29 | alias PutResult = BitFlags!PutResultFlag; 30 | 31 | // I failed to reach both goals: inheritance from interface and nogc/nothrow attribute neutrality 32 | // for Cache implementations. So I droped inheritance. 33 | // 34 | //interface Cache(K, V) { 35 | // 36 | // // get value from cache 37 | // Nullable!V get(K) @safe; 38 | // 39 | // // put/update cache entry 40 | // PutResult put(K, V) @safe; 41 | // 42 | // // remove key 43 | // bool remove(K) @safe; 44 | // 45 | // // clear entire cache 46 | // void clear() @safe; 47 | // 48 | // // # of elements 49 | // size_t length() const @safe; 50 | // 51 | //} 52 | 53 | enum EventType 54 | { 55 | Removed, 56 | Expired, 57 | Evicted, 58 | Updated 59 | } 60 | 61 | struct CacheEvent(K, V) 62 | { 63 | EventType event; 64 | StoredType!K key; 65 | StoredType!V val; 66 | } 67 | 68 | /** 69 | * TTL encapsulate ttl for single cache item 70 | 1. use default - __ttl = 0 71 | 2. no ttl - __ttl = -1 72 | 3. some value - __ttl > 0 73 | */ 74 | struct TTL { 75 | 76 | private Duration __ttl = 0.seconds; 77 | 78 | /// 79 | /// True if this TTL means - use default value for this cache 80 | /// 81 | bool useDefault() pure const nothrow @nogc @safe { 82 | return __ttl == 0.seconds; 83 | } 84 | /// 85 | /// return value encapsulated by this ttl 86 | /// 87 | Duration value() pure const nothrow @nogc @safe { 88 | return __ttl; 89 | } 90 | /// 91 | /// Create "no ttl" - means do not use ttl with this entry 92 | /// 93 | TTL opUnary(string op)() pure nothrow @safe @nogc if (op == "~") 94 | { 95 | return TTL(-1.seconds); 96 | } 97 | /** 98 | / Constructor 99 | / Parameters: 100 | / v - ttl value (0 - use default value or no ttl if there is no defaults) 101 | */ 102 | this(Duration v) pure nothrow @safe @nogc { 103 | __ttl = v; 104 | } 105 | deprecated("Use TTL(Duration) instead") 106 | this(int v) pure nothrow @safe @nogc 107 | { 108 | __ttl = v.seconds; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /source/cachetools/internal.d: -------------------------------------------------------------------------------- 1 | module cachetools.internal; 2 | 3 | private import std.typecons; 4 | private import std.traits; 5 | 6 | template StoredType(T) 7 | { 8 | static if ( is (T==immutable) || is(T==const) ) 9 | { 10 | static if ( is(T==class) ) 11 | { 12 | alias StoredType = Rebindable!T; 13 | } 14 | else 15 | { 16 | alias StoredType = Unqual!T; 17 | } 18 | } 19 | else 20 | { 21 | alias StoredType = T; 22 | } 23 | } 24 | 25 | import std.experimental.logger; 26 | 27 | debug(cachetools) @safe @nogc nothrow 28 | { 29 | void safe_tracef(A...)(string f, scope A args, string file = __FILE__, int line = __LINE__) @safe @nogc nothrow 30 | { 31 | debug (cachetools) try 32 | { 33 | () @trusted @nogc {tracef("%s:%d " ~ f, file, line, args);}(); 34 | } 35 | catch(Exception e) 36 | { 37 | } 38 | } 39 | } 40 | 41 | bool UseGCRanges(T)() { 42 | return hasIndirections!T; 43 | } 44 | 45 | bool UseGCRanges(Allocator, T, bool GCRangesAllowed)() 46 | { 47 | import std.experimental.allocator.gc_allocator; 48 | return !is(Allocator==GCAllocator) && hasIndirections!T && GCRangesAllowed; 49 | } 50 | 51 | bool UseGCRanges(Allocator, K, V, bool GCRangesAllowed)() 52 | { 53 | import std.experimental.allocator.gc_allocator; 54 | 55 | return !is(Allocator == GCAllocator) && (hasIndirections!K || hasIndirections!V ) && GCRangesAllowed; 56 | } 57 | 58 | /// 59 | /// Return true if it is worth to store values inline in hash table 60 | /// V footprint should be small enough 61 | /// 62 | package bool SmallValueFootprint(V)() { 63 | import std.traits; 64 | 65 | static if (isNumeric!V || isSomeString!V || isSomeChar!V || isPointer!V) { 66 | return true; 67 | } 68 | else static if (is(V == struct) && V.sizeof <= (void*).sizeof) { 69 | return true; 70 | } 71 | else static if (is(V == class) && __traits(classInstanceSize, V) <= (void*).sizeof) { 72 | return true; 73 | } 74 | else 75 | return false; 76 | } 77 | -------------------------------------------------------------------------------- /source/cachetools/package.d: -------------------------------------------------------------------------------- 1 | module cachetools; 2 | 3 | public import cachetools.interfaces; 4 | public import cachetools.cache; 5 | public import cachetools.containers.hashmap; 6 | public import cachetools.hash; 7 | 8 | private import cachetools.internal; 9 | 10 | -------------------------------------------------------------------------------- /testhash/.gitignore: -------------------------------------------------------------------------------- 1 | .dub 2 | docs.json 3 | __dummy.html 4 | docs/ 5 | testhash.so 6 | testhash.dylib 7 | testhash.dll 8 | testhash.a 9 | testhash.lib 10 | testhash-test-* 11 | *.exe 12 | *.o 13 | *.obj 14 | *.lst 15 | -------------------------------------------------------------------------------- /testhash/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "testhash", 3 | "authors": [ 4 | "Igor Khasilev" 5 | ], 6 | "dependencies": { 7 | "cachetools": "*", 8 | "emsi_containers": "*" 9 | }, 10 | "description": "Performance tests for hash tables", 11 | "copyright": "Copyright © 2018, Igor Khasilev", 12 | "license": "MIT" 13 | } 14 | --------------------------------------------------------------------------------