Kenneth Love avatar Kenneth Love committed 0622e13

adding strings and sets with TTLs works

Comments (0)

Files changed (2)

     """
     key_name = TextField('Key', validators=[Required()])
     member = TextField('Member', validators=[Required()])
+    key_ttl = IntegerField('TTL')
 
 # Context processors
 @app.context_processor
     if form.validate_on_submit():
         key = request.form['key_name']
         value = request.form['key_value']
+        ttl = request.form['key_ttl']
 
         r = get_redis_connection(session)
         if not r:
 
         try:
             r.set(key, value)
+            if ttl and ttl != 0:
+                r.expire(key, ttl)
+
             flash('%s was saved successfully.' % key)
             return redirect('#%s' % key)
         except:
     if form.validate_on_submit():
         key = request.form['key_name']
         member = request.form['member']
+        ttl = request.form['key_ttl']
 
         r = get_redis_connection(session)
         if not r:
 
         result = r.sadd(key, member)
 
+        if ttl and ttl != 0:
+            r.expire(key, ttl)
+
         if result:
             flash('%s was created.' % key)
         else:

templates/new_set.html

 		{{ form.csrf }}
 		{{ render_field(form.key_name) }}
 		{{ render_field(form.member) }}
+		{{ render_field(form.key_ttl, type="number", class="optional") }}
 		<a href="{{ url_for('index') }}" id="cancel">cancel</a>
 		<input type="submit" value="Submit">
 	</form>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.