couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Regenerating views on update" by PaulCarey
Date Wed, 11 Mar 2009 08:24:01 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The following page has been changed by PaulCarey:
http://wiki.apache.org/couchdb/Regenerating_views_on_update

The comment on the change is:
Updated for trunk

------------------------------------------------------------------------------
  	DbUpdateNotificationProcess=/PATH/TO/view_updater.rb
  }}}
  
- (0.9) Add the following section to the couch.ini file: {{{
+ (0.9) Add the following section to the local.ini file: {{{
  [update_notification]
  view_updater=/PATH/TO/view_updater.rb
  }}}  
  
  === view_updater.rb ===
- The following script updates the views for each tenth update made to the database or at
most once every second when a lot of saves are performed {{{
+ The following script updates the views for each tenth update made to the database or at
most once every second when a lot of saves are performed 
+ 
+ {{{
+ 
  #!/usr/bin/ruby
  
  ###################
@@ -26, +29 @@

  ###################
  
  # The smallest amount of changed documents before the views are updated
- MIN_NUM_OF_CHANGED_DOCS = 10
+ MIN_NUM_OF_CHANGED_DOCS = 1
  
  # URL to the DB on the CouchDB server
  URL = "http://localhost:5984"
@@ -36, +39 @@

  
  # One entry for each design document 
  # in each database
+ VIEWS = {"my_db"  => {"design_doc" => "view_name"}}
- VIEWS = {"DATABASE_NAME"  => ["list_of/design_documents",
-                               "another/design_document"],
-          "recipes"        => ["category/most_popular"],
-          "ingredients"    => ["by/price"]}        
-         
  
  ###################
  # RUNTIME         #
@@ -64, +63 @@

          
          # If there are views in the database, get them
          if VIEWS[db_name]
-           VIEWS[db_name].each do |view|
+           VIEWS[db_name].each do |design, view|
-             `curl #{URL}/#{db_name}/_view/#{view}?count=0`
+             `curl #{URL}/#{db_name}/_design/#{design}/_view/#{view}?limit=0`
            end  
          end
                  
@@ -84, +83 @@

  
    while run do
  
-     puts "Waiting for input:"
+     STDERR << "Waiting for input\n"
      update_call = gets
      
      # When CouchDB exits the script gets called with

Mime
View raw message