Skip to content

Commit cb16af6

Browse files
committed
Add notes about chaining to README
1 parent 0b8339f commit cb16af6

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ This is the model you should extend.
9494

9595
**Deprecated Fields:**
9696

97+
The following class-level items have been deprecated in 4.0 and may be removed in a future version of IndexedRedis.
98+
99+
97100
*BINARY_FIELDS* - A list of strings containing the names of fields which will be stored directly as unencoded bytes. This is generally faster and more space-efficient than using BASE64\_FIELDS, and should be used for purely binary data.
98101

99102
Example: ['picture', 'mp3_data']
@@ -166,6 +169,8 @@ e.x.
166169

167170
An entry in "FIELDS" that is just a string name ( pre 4.0 style ) will be treated same as IRField('myname', valueType=str), and behaves exactly the same, so models are backwards-compatible.
168171

172+
These objects (all importable from IndexedRedis.fields) can all be put in the FIELDS array.
173+
169174

170175
*IRField* - Standard field, takes a name and a "valueType", which is a native python type, or any type you create which implements \_\_new\_\_, taking a signle argument and returning the object. See IndexedRedis/fields/FieldValueTypes for example of how datetime and json are implemented.
171176

@@ -188,6 +193,26 @@ When no valueType is defined, str/unicode is the type (same as pre-4.0), and def
188193
*IRRawField* - Field that is not converted in any, to or from Redis. On fetch this will always be "bytes" type (or str in python2). On python3 this is very similar to IRField(...valueType=None), but python2 needs this to store binary data without running into encoding issues.
189194

190195

196+
**Chaining Multiple Types**
197+
198+
You can chain multiple types together using IRFieldChain. Instead of specifying the name on the IRField (or subclass), you specify the name on the IRFieldChain, and list all the types as the second argument (chainedFields). For storage, all operations will be applied left-to-right, and upon fetch the object will be decoded right-to-left.
199+
200+
Example:
201+
202+
FIELDS = [ \
203+
204+
...
205+
206+
IRChainField( 'longData', [ IRUnicodeField(encoding='utf-16'), IRCompressedField() ] )
207+
]
208+
209+
In the above example, you provide "longData" as a string.
210+
211+
For storage, that string is assumed to be utf-16, and will be compressed (left-to-right)
212+
213+
For fetching, that string is first decompressed, and then encoded using utf-16.
214+
215+
191216
Model Validation
192217
----------------
193218

README.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ This is the model you should extend.
109109

110110
**Deprecated Fields:**
111111

112+
The following class-level items have been deprecated in 4.0 and may be removed in a future version of IndexedRedis.
113+
114+
112115
*BINARY_FIELDS* - A list of strings containing the names of fields which will be stored directly as unencoded bytes. This is generally faster and more space-efficient than using BASE64\_FIELDS, and should be used for purely binary data.
113116

114117
Example: ['picture', 'mp3_data']
@@ -181,6 +184,8 @@ e.x.
181184

182185
An entry in "FIELDS" that is just a string name ( pre 4.0 style ) will be treated same as IRField('myname', valueType=str), and behaves exactly the same, so models are backwards-compatible.
183186

187+
These objects (all importable from IndexedRedis.fields) can all be put in the FIELDS array.
188+
184189

185190
*IRField* - Standard field, takes a name and a "valueType", which is a native python type, or any type you create which implements \_\_new\_\_, taking a signle argument and returning the object. See IndexedRedis/fields/FieldValueTypes for example of how datetime and json are implemented.
186191

@@ -203,6 +208,27 @@ When no valueType is defined, str/unicode is the type (same as pre-4.0), and def
203208
*IRRawField* - Field that is not converted in any, to or from Redis. On fetch this will always be "bytes" type (or str in python2). On python3 this is very similar to IRField(...valueType=None), but python2 needs this to store binary data without running into encoding issues.
204209

205210

211+
**Chaining Multiple Types**
212+
213+
You can chain multiple types together using IRFieldChain. Instead of specifying the name on the IRField (or subclass), you specify the name on the IRFieldChain, and list all the types as the second argument (chainedFields). For storage, all operations will be applied left-to-right, and upon fetch the object will be decoded right-to-left.
214+
215+
Example:
216+
217+
FIELDS = [ \\
218+
219+
...
220+
221+
IRChainField( 'longData', [ IRUnicodeField(encoding='utf-16'), IRCompressedField() ] )
222+
223+
]
224+
225+
In the above example, you provide "longData" as a string.
226+
227+
For storage, that string is assumed to be utf-16, and will be compressed (left-to-right)
228+
229+
For fetching, that string is first decompressed, and then encoded using utf-16.
230+
231+
206232
Model Validation
207233
----------------
208234

0 commit comments

Comments
 (0)