forked from apex-enterprise-patterns/fflib-apex-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketching out the idea of the sobject cache
- Loading branch information
1 parent
3f1ea97
commit 6a6ba9f
Showing
14 changed files
with
256 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
framework/default/ortoo-core/default/classes/fflib-extension/caching/ICacheAdaptor.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
public interface ICacheAdaptor | ||
{ | ||
Boolean isACache(); | ||
Object get( String key ); | ||
void put( String key, Object value, Integer lifespan ); | ||
Set<String> getKeys(); | ||
Boolean contains( String key ); | ||
void remove( String key ); | ||
String createFullyQualifiedPartitionName( String namespace, String partitionName ); | ||
String createFullyQualifiedKey( String namespace, String partitionName, String subKey ); | ||
} |
File renamed without changes.
40 changes: 40 additions & 0 deletions
40
framework/default/ortoo-core/default/classes/fflib-extension/caching/NullCache.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
public class NullCache implements ICacheAdaptor | ||
{ | ||
public Boolean isACache() | ||
{ | ||
return false; | ||
} | ||
|
||
public Object get( String key ) | ||
{ | ||
return null; | ||
} | ||
|
||
public void put( String key, Object value, Integer lifespan ) // NOPMD: Intentionally left empty, as this should do nothing in a NullCache | ||
{ | ||
} | ||
|
||
public Set<String> getKeys() | ||
{ | ||
return new Set<String>(); | ||
} | ||
|
||
public Boolean contains( String key ) | ||
{ | ||
return false; | ||
} | ||
|
||
public void remove( String key ) // NOPMD: Intentionally left empty, as this should do nothing in a NullCache | ||
{ | ||
} | ||
|
||
public String createFullyQualifiedPartitionName( String namespace, String partitionName ) | ||
{ | ||
return namespace + '.' + partitionName; | ||
} | ||
|
||
public String createFullyQualifiedKey( String namespace, String partitionName, String subKey ) | ||
{ | ||
return namespace + '.' + partitionName + '.' + subkey; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
framework/default/ortoo-core/default/classes/fflib-extension/caching/NullCache.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>52.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
42 changes: 42 additions & 0 deletions
42
framework/default/ortoo-core/default/classes/fflib-extension/caching/OrgCache.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
public class OrgCache implements ICacheAdaptor | ||
{ | ||
public Boolean isACache() | ||
{ | ||
return true; | ||
} | ||
|
||
public Object get( String key ) | ||
{ | ||
return Cache.Org.get( key ); | ||
} | ||
|
||
public void put( String key, Object value, Integer lifespan ) | ||
{ | ||
Cache.Org.put( key, value, lifespan, Cache.Visibility.NAMESPACE, true ); // immutable outside of namespace | ||
} | ||
|
||
public Set<String> getKeys() | ||
{ | ||
return Cache.Org.getKeys(); | ||
} | ||
|
||
public Boolean contains( String key ) | ||
{ | ||
return Cache.Org.contains( key ); | ||
} | ||
|
||
public void remove( String key ) | ||
{ | ||
Cache.Org.remove( key ); | ||
} | ||
|
||
public String createFullyQualifiedPartitionName( String namespace, String partitionName ) | ||
{ | ||
return Cache.OrgPartition.createFullyQualifiedPartition( namespace, partitionName ); | ||
} | ||
|
||
public String createFullyQualifiedKey( String namespace, String partitionName, String subKey ) | ||
{ | ||
return Cache.OrgPartition.createFullyQualifiedKey( namespace, partitionName, subkey ); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
framework/default/ortoo-core/default/classes/fflib-extension/caching/OrgCache.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>52.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
42 changes: 42 additions & 0 deletions
42
framework/default/ortoo-core/default/classes/fflib-extension/caching/SessionCache.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
public class SessionCache implements ICacheAdaptor | ||
{ | ||
public Boolean isACache() | ||
{ | ||
return true; | ||
} | ||
|
||
public Object get( String key ) | ||
{ | ||
return Cache.Session.get( key ); | ||
} | ||
|
||
public void put( String key, Object value, Integer lifespan ) | ||
{ | ||
Cache.Session.put( key, value, lifespan, Cache.Visibility.NAMESPACE, true ); // immutable outside of namespace | ||
} | ||
|
||
public Set<String> getKeys() | ||
{ | ||
return Cache.Session.getKeys(); | ||
} | ||
|
||
public Boolean contains( String key ) | ||
{ | ||
return Cache.Session.contains( key ); | ||
} | ||
|
||
public void remove( String key ) | ||
{ | ||
Cache.Session.remove( key ); | ||
} | ||
|
||
public String createFullyQualifiedPartitionName( String namespace, String partitionName ) | ||
{ | ||
return Cache.SessionPartition.createFullyQualifiedPartition( namespace, partitionName ); | ||
} | ||
|
||
public String createFullyQualifiedKey( String namespace, String partitionName, String subKey ) | ||
{ | ||
return Cache.SessionPartition.createFullyQualifiedKey( namespace, partitionName, subkey ); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...work/default/ortoo-core/default/classes/fflib-extension/caching/SessionCache.cls-meta.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>52.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
Oops, something went wrong.