Nilable indexes taken into account.
This commit is contained in:
parent
6dbcee5060
commit
8a44828cf2
@ -95,15 +95,6 @@ class DODB::CachedDataBase(V) < DODB::Storage(V)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :inherit:
|
|
||||||
def delete(key : Int32)
|
|
||||||
request_lock "key"
|
|
||||||
value = unsafe_delete key
|
|
||||||
release_lock "key"
|
|
||||||
|
|
||||||
value
|
|
||||||
end
|
|
||||||
|
|
||||||
# :inherit:
|
# :inherit:
|
||||||
def unsafe_delete(key : Int32)
|
def unsafe_delete(key : Int32)
|
||||||
value = self[key]?
|
value = self[key]?
|
||||||
|
35
src/dodb.cr
35
src/dodb.cr
@ -160,7 +160,7 @@ abstract class DODB::Storage(V)
|
|||||||
|
|
||||||
# Creates a new basic index **with a cache**.
|
# Creates a new basic index **with a cache**.
|
||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
def new_index(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_index(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
CachedIndex(V).new(self, @directory_name, name, block).tap do |indexer|
|
CachedIndex(V).new(self, @directory_name, name, block).tap do |indexer|
|
||||||
@indexers << indexer
|
@indexers << indexer
|
||||||
end
|
end
|
||||||
@ -170,7 +170,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this will be a lot slower than the cached version.
|
# NOTE: this will be a lot slower than the cached version.
|
||||||
def new_uncached_index(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_uncached_index(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
Index(V).new(self, @directory_name, name, block).tap do |indexer|
|
Index(V).new(self, @directory_name, name, block).tap do |indexer|
|
||||||
@indexers << indexer
|
@indexers << indexer
|
||||||
end
|
end
|
||||||
@ -180,7 +180,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this index is the fastest, but doesn't have a file-system representation.
|
# NOTE: this index is the fastest, but doesn't have a file-system representation.
|
||||||
def new_RAM_index(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_RAM_index(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
RAMOnlyIndex(V).new(self, @directory_name, name, block).tap do |indexer|
|
RAMOnlyIndex(V).new(self, @directory_name, name, block).tap do |indexer|
|
||||||
@indexers << indexer
|
@indexers << indexer
|
||||||
end
|
end
|
||||||
@ -194,7 +194,7 @@ abstract class DODB::Storage(V)
|
|||||||
|
|
||||||
# Creates a new partition **with a cache**.
|
# Creates a new partition **with a cache**.
|
||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
def new_partition(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_partition(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
CachedPartition(V).new(self, @directory_name, name, block).tap do |table|
|
CachedPartition(V).new(self, @directory_name, name, block).tap do |table|
|
||||||
@indexers << table
|
@indexers << table
|
||||||
end
|
end
|
||||||
@ -204,7 +204,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this will be a lot slower than the cached version.
|
# NOTE: this will be a lot slower than the cached version.
|
||||||
def new_uncached_partition(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_uncached_partition(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
Partition(V).new(self, @directory_name, name, block).tap do |table|
|
Partition(V).new(self, @directory_name, name, block).tap do |table|
|
||||||
@indexers << table
|
@indexers << table
|
||||||
end
|
end
|
||||||
@ -214,7 +214,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this partition index is the fastest but doesn't have a file-system representation.
|
# NOTE: this partition index is the fastest but doesn't have a file-system representation.
|
||||||
def new_RAM_partition(name : String, &block : Proc(V, String) | Proc(V, String | DODB::NoIndex))
|
def new_RAM_partition(name : String, &block : Proc(V, String | DODB::NoIndex))
|
||||||
RAMOnlyPartition(V).new(self, @directory_name, name, block).tap do |table|
|
RAMOnlyPartition(V).new(self, @directory_name, name, block).tap do |table|
|
||||||
@indexers << table
|
@indexers << table
|
||||||
end
|
end
|
||||||
@ -228,7 +228,7 @@ abstract class DODB::Storage(V)
|
|||||||
|
|
||||||
# Creates a new tag **with a cache**.
|
# Creates a new tag **with a cache**.
|
||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
def new_tags(name : String, &block : Proc(V, Array(String)) | Proc(V, Array(String) | DODB::NoIndex))
|
def new_tags(name : String, &block : Proc(V, Array(String) | DODB::NoIndex))
|
||||||
CachedTags(V).new(self, @directory_name, name, block).tap do |tags|
|
CachedTags(V).new(self, @directory_name, name, block).tap do |tags|
|
||||||
@indexers << tags
|
@indexers << tags
|
||||||
end
|
end
|
||||||
@ -238,7 +238,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this will be a lot slower than the cached version.
|
# NOTE: this will be a lot slower than the cached version.
|
||||||
def new_uncached_tags(name : String, &block : Proc(V, Array(String)) | Proc(V, Array(String) | DODB::NoIndex))
|
def new_uncached_tags(name : String, &block : Proc(V, Array(String) | DODB::NoIndex))
|
||||||
Tags(V).new(self, @directory_name, name, block).tap do |tags|
|
Tags(V).new(self, @directory_name, name, block).tap do |tags|
|
||||||
@indexers << tags
|
@indexers << tags
|
||||||
end
|
end
|
||||||
@ -248,7 +248,7 @@ abstract class DODB::Storage(V)
|
|||||||
# The *name* parameter is the name of the directory that will be created.
|
# The *name* parameter is the name of the directory that will be created.
|
||||||
#
|
#
|
||||||
# NOTE: this tag index is the fastest but doesn't have a file-system representation.
|
# NOTE: this tag index is the fastest but doesn't have a file-system representation.
|
||||||
def new_RAM_tags(name : String, &block : Proc(V, Array(String)) | Proc(V, Array(String) | DODB::NoIndex))
|
def new_RAM_tags(name : String, &block : Proc(V, Array(String) | DODB::NoIndex))
|
||||||
RAMOnlyTags(V).new(self, @directory_name, name, block).tap do |tags|
|
RAMOnlyTags(V).new(self, @directory_name, name, block).tap do |tags|
|
||||||
@indexers << tags
|
@indexers << tags
|
||||||
end
|
end
|
||||||
@ -373,7 +373,13 @@ abstract class DODB::Storage(V)
|
|||||||
abstract def unsafe_delete(key : Int32)
|
abstract def unsafe_delete(key : Int32)
|
||||||
|
|
||||||
# Deletes the data with the *key*.
|
# Deletes the data with the *key*.
|
||||||
abstract def delete(key : Int32)
|
def delete(key : Int32)
|
||||||
|
request_lock "key"
|
||||||
|
value = unsafe_delete key
|
||||||
|
release_lock "key"
|
||||||
|
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DODB::DataBase(V) < DODB::Storage(V)
|
class DODB::DataBase(V) < DODB::Storage(V)
|
||||||
@ -420,15 +426,6 @@ class DODB::DataBase(V) < DODB::Storage(V)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# :inherit:
|
|
||||||
def delete(key : Int32)
|
|
||||||
request_lock "key"
|
|
||||||
value = unsafe_delete key
|
|
||||||
release_lock "key"
|
|
||||||
|
|
||||||
value
|
|
||||||
end
|
|
||||||
|
|
||||||
# :inherit:
|
# :inherit:
|
||||||
def unsafe_delete(key : Int32)
|
def unsafe_delete(key : Int32)
|
||||||
value = self[key]?
|
value = self[key]?
|
||||||
|
Loading…
Reference in New Issue
Block a user