UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'WrSloDhoa+vkNuOHxAfpaHMY4f0FvX5xllS5o6ekiA0='
WHERE
key_id = 'a8b90b5d83931b038c6e54a5fed65cd824749bfb2ae8d1cd234467df5abb834d'
AND (
token = 'WrSloDhoa+vkNuOHxAfpaHMY4f0FvX5xllS5o6ekiA0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)