UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HhJTAxbtLYNRnJTJ5iWFpcUc3FO9YJScRxSh8pBwkH4=' 
WHERE 
  key_id = '77f3cd0e6b521b242f75e5f6efbb7077580857887a98e565a895ac1092f42011' 
  AND (
    token = 'HhJTAxbtLYNRnJTJ5iWFpcUc3FO9YJScRxSh8pBwkH4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040