Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryableCache.cfc
More file actions
Latest commit
120 lines (89 loc) · 3.45 KB
/
Copy pathQueryableCache.cfc
File metadata and controls
120 lines (89 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
componentimplements ="lib.sql.IQueryable" {
/*
an extension of the IQueryable interface to leverage on top of a persistent searchable cache
implementations:
- https://github.com/DonorDrive/ehcache
- https://github.com/DonorDrive/redis
these methods assume that the identifierField defined will be furnished as a named argument (or in the case of putRow, a member of the furnished struct)
this may make sense to implement as an Abstract component down the road...
*/
booleanfunctioncontainsRow() {
throw(type ="lib.sql.MethodNotImplementedException");
}
queryfunctionexecuteSelect(requiredlib.sql.SelectStatementselectStatement, requirednumericlimit, requirednumericoffset) {
throw(type ="lib.sql.MethodNotImplementedException");
}
booleanfunctionfieldExists(requiredstringfieldName) {
returnvariables.queryable.fieldExists(arguments.fieldName);
}
booleanfunctionfieldIsFilterable(requiredstringfieldName) {
returnvariables.queryable.fieldIsFilterable(arguments.fieldName);
}
stringfunctiongetFieldList() {
returnvariables.queryable.getFieldList();
}
stringfunctiongetFieldSQL(requiredstringfieldName) {
return"";
}
stringfunctiongetFieldSQLType(requiredstringfieldName) {
returnvariables.queryable.getFieldSQLType(arguments.fieldName);
}
stringfunctiongetIdentifierField() {
returnvariables.queryable.getIdentifierField();
}
lib.sql.IQueryablefunctiongetQueryable() {
returnvariables.queryable;
}
anyfunctiongetRow() {
throw(type ="lib.sql.MethodNotImplementedException");
}
stringfunctiongetRowKey() {
local.rowKey=getRowKeyMask();
local.pos=find("{", local.rowKey);
do {
local.end=find("}", local.rowKey, local.pos);
local.keyArg=mid(local.rowKey, local.pos+1, local.end-local.pos-1);
local.rowKey=replace(local.rowKey, "{#local.keyArg#}", REReplace(arguments[local.keyArg], "[^A-Za-z0-9]", "", "all"));
local.pos=find("{", local.rowKey);
} while(local.pos>0);
returnlCase(local.rowKey);
}
stringfunctiongetRowKeyMask() {
returnvariables.rowKeyMask;
}
voidfunctionputRow(requiredstructrow) {
throw(type ="lib.sql.MethodNotImplementedException");
}
voidfunctionremoveRow() {
throw(type ="lib.sql.MethodNotImplementedException");
}
voidfunctionseedFromQueryable(booleanoverwrite=false, stringwhere="") {
throw(type ="lib.sql.MethodNotImplementedException");
}
lib.sql.SelectStatementfunctionselect(stringfieldList="*") {
returnnewlib.sql.SelectStatement(this).select(arguments.fieldList);
}
lib.sql.QueryableCachefunctionsetQueryable(requiredlib.sql.IQueryablequeryable) {
variables.queryable=arguments.queryable;
returnthis;
}
lib.sql.QueryableCachefunctionsetRowKeyMask(requiredstringrowKeyMask) {
if(!structKeyExists(variables, "queryable")) {
throw(type ="lib.ehcache.UndefinedQueryableException", message ="an IQueryable must be furnished before defining rowKeyMask");
}
local.rowKeyMask=listReduce(
getFieldList(),
function(result, keyField) {
returnreplaceNoCase(arguments.result, "{#arguments.keyField#}", "");
},
arguments.rowKeyMask
);
if(find("{", local.rowKeyMask) || find("}", local.rowKeyMask)) {
throw(type ="lib.ehcache.KeyMaskParsingException");
} else if(local.rowKeyMask==arguments.rowKeyMask) {
throw(type ="lib.ehcache.KeyMaskParsingException");
}
variables.rowKeyMask=lCase(arguments.rowKeyMask);
returnthis;
}
}