Writing own storage: Difference between revisions

From Sunhill Framework Documentation
+ Standard storages
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
When '''writing your own storage''' first check if you can use on of these storages as a base:
When '''writing your own storage''' first check if you can use on of these storages as a base:
* [[SimpleStorage]]
* [[SimpleStorage]]
* [[PersistentSingleStorage]]
* [[PersistentPoolStorage]]


If you can't use one of the above you have to overwrite the following abstract methods
If you can't use one of the above you have to overwrite the following abstract methods
Line 25: Line 27:
=== doSetIndexedValue(string $name, $index, $value) ===
=== doSetIndexedValue(string $name, $index, $value) ===
Sets in the array property $name the element identified by $index with $value
Sets in the array property $name the element identified by $index with $value
=== isDirty(): bool ===
Returns if the storage was modified.
=== doCommit() ===
For cached storages performs the flush of the cache. Has to be called by property.
   
=== doRollback() ===
For cached storages performs the reollback of the cache. Has to be called by property.


=== doGetIsInitialized(string $name): bool ===
=== doGetIsInitialized(string $name): bool ===
Line 39: Line 32:


== Optional methods ==
== Optional methods ==
=== isDirty(): bool ===
Returns if the storage was modified. Overwrite when storage is writeable and can be modified. (for persistant storage use [[Persistant storage]]).


=== prepareGetValue(string $name) ===
=== prepareGetValue(string $name) ===
Line 47: Line 43:
=== postprocessSetValue(string $name, $value) ===
=== postprocessSetValue(string $name, $value) ===
Perfoms action after setting the value
Perfoms action after setting the value
 
 
[[Category:Storages]]
[[Category:Storages]]
[[Category:Properties]]
[[Category:Properties]]

Latest revision as of 09:09, 17 October 2024

When writing your own storage first check if you can use on of these storages as a base:

If you can't use one of the above you have to overwrite the following abstract methods

Abstract methods

doGetValue(string $name)

Performs the retrievement of the value.

doGetIndexedValue(string $name, mixed $index): mixed

Gets from the array element $name the entry identified by $index Note: This routine does not check, if the element is an array at all. This has do be done by the owning property

doGetElementCount(string $name): int

Gets from the array element $name the count of entries. Note: This routine does not check, if the element is an array at all. This has do be done by the owning property

doGetOffsetExists(string $name, $index): bool

Returns how many entries the array element has. Note: '

doSetValue(string $name, $value)

Performs the setting of the value

doSetIndexedValue(string $name, $index, $value)

Sets in the array property $name the element identified by $index with $value

doGetIsInitialized(string $name): bool

Returns if this storage was initialized

Optional methods

isDirty(): bool

Returns if the storage was modified. Overwrite when storage is writeable and can be modified. (for persistant storage use Persistant storage).

prepareGetValue(string $name)

Prepares the retrievement of the value

doGetKeys(string $name): array

postprocessSetValue(string $name, $value)

Perfoms action after setting the value