UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'w8NZIFJa1pLwjlDcYRpoWIiVBfOjekvrEx1HsPmhA4o=' 
WHERE 
  key_id = '166cee6b27789285939861298a425c873b6ab28e72e077aae8e9145f066bbe67' 
  AND (
    token = 'w8NZIFJa1pLwjlDcYRpoWIiVBfOjekvrEx1HsPmhA4o=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040