UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'm8AoUiWgnjwuXNWoeV1g+7D1geIhMnVzqvOLe7UwwDQ=' 
WHERE 
  key_id = '240ce8c6bec595425f806166d4ecb77508778f1ed181605e243567f1783aa4b2' 
  AND (
    token = 'm8AoUiWgnjwuXNWoeV1g+7D1geIhMnVzqvOLe7UwwDQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038